home *** CD-ROM | disk | FTP | other *** search
- Path: d1o2.telia.com!usenet
- From: <>
- Newsgroups: comp.lang.c
- Subject: Re: big problem with a very small program:please help me!
- Date: 12 Mar 1996 10:40:08 GMT
- Organization: Telia Internet Services
- Message-ID: <4i3ka8$m3n@d1o2.telia.com>
- NNTP-Posting-Host: t6o1p3.telia.com
-
- escali_m@worldnet.net (Marc Escalier) skriver:
- > #include <stdio.h>
- > #include <math.h>
- >
- > main()
- > {
- > float i;
- >
- > i=5.25;
- > printf("i is real:l%f\n",i); /* display 5.25000000000000... ok! */
- > printf("i is integer%d\n",i); /* display 0 what does that mean
- > ?!?*/
- > return(0);
- > }
- >
- > thanx for any help.
- > please answer by email because i don't read often comp.lang.c.
- >
-
- You must do a cast like this:
- printf( "i is integer %d\n", ( int ) i );
-
- This is because the printf function parameter %d expects a variable value
- formatted as an integer and not as a float, which i is.
-
- Try this and good luck!
-
- /Erik
-
-
-